
function showInfo(id, edit_type, editheight1) {
	if(!editheight1) editheight1 = editheight;
	if(!edit_type) edit_type = '';
	var ch = Math.max(editheight1, 150);
	<? if($isphone) { ?>
		ch = parseInt(document.documentElement.clientHeight*0.9);

	<? } ?>
	
	show_fdiv(800, ch);
	$("infocontent").innerHTML = '载入中...';
	
	var post = {'id': id};
	if(editparam && editparam != '') {
		for(var i in editparam) {
			 post[i] = editparam[i];
		}
	}
	$G.ajax("?act=show&showtype="+showtype+"&edit_type="+edit_type, post, function(rs) {
		if(!check_rs(rs)) {
			hideInfo();
			return ;
		}

		$("infocontent").innerHTML = rs.data.html;
		edit_data = null;
		if(rs.data.edit_id > 0 && rs.data.edit_data) edit_data = rs.data.edit_data;
		editable = rs.data.editable;
		
		if(typeof(JSON) != 'undefined' && typeof(JSON.parse) != 'undefined' && typeof(JSON.stringify) != 'undefined') editable_o = JSON.parse(JSON.stringify(rs.data.editable));
		else editable_o = $G.deepCopy(rs.data.editable);

		if( rs.data.extraJs != '') {
			eval(rs.data.extraJs);
		}
		
		

	}, 'json', 'POST');
}


function checkCellphone(num, name) {
	if(!/^1\d{10}$/.test(num)) {
		alert("手机号格式不正确！");
		return false;
	}
	return true;
}

function delIt(id, type) {
	var op = '删除';
	var optype = 1;
	if(type && type == 1) {
		optype = 2;
		op = '恢复';
	}
	if(!confirm("确定要"+op+"？")) return ;

	var post = {'id': id, 'optype': optype};
	if(editparam && editparam != '') {
		for(var i in editparam) {
			 post[i] = editparam[i];
		}
	}
	
	$G.ajax("?act=show&showtype="+showtype+"&m=del", post, function(rs) {
		if(!check_rs(rs)) return;
		getListData();
	}, 'json', 'POST');
}


var lastPage = 1;
var lastSearchParams = {};
function getListData(page, params, isexport, bt) {
	if(!page || page == null) page = lastPage;
	if(!params || params == null) params = lastSearchParams;

	var url = "?act=list&showtype="+showtype+"&page="+page;
	var text_r = '';
	if(isexport) {
		if(bt) {
			text_r = bt.value;
			bt.disabled = true;
			bt.value = '正在导出...';
		}
		url += '&m=export';
	} else {
		var waitstr = '';
		//if(show_loading == '1') 
			waitstr = '载入中...';
		try{ $("list_content").innerHTML = waitstr;} catch(e) { }
	}
	if(editparam && editparam != '') {
		for(var i in editparam) {
			params[i] = editparam[i];
		}
	}
	$G.ajax(url, params, function(rs) {
		if(isexport) {
			if(bt) {
				bt.disabled = false;
				bt.value = text_r;
			}
		}
		if(!check_rs(rs)) return ;
		if(isexport) {
			location.href = rs.data.url;
		} else {
			lastPage = page;
			lastSearchParams = params;
			try{ 
				$("list_content").innerHTML = rs.data.html;
				//var w = $('list_table').offsetWidth;
				//if(w < 500) w = 500;
				//$("list_content").style.width = (w+10)+'px';
			} catch(e) { }
		}
		
	}, 'json', 'POST');
}

function search(p_key, p_value) {
	var params = {};
	if(search_items) {
		for(var i = 0; i < search_items.length; i++) {
			var item = search_items[i];
			var key = item.key;
			var value = '';
			if(p_key && key == p_key) {
				value = p_value;
			} else {
				value = $G.getValue("search-"+key);
			}

			params['search_'+key] = value;
		}
	}
	getListData(1, params);
}




function edit_set_must(name, must) {
	if(typeof(editable[name]) == 'undefined') return;
	if(typeof(must) == 'undefined') must = editable_o[name]['must'];
	editable[name]['must'] = must;
	$("edit_title_star_"+name).style.display = (must==1?"":"none");
}

function edit_set_grp_must(grp, must) {
	for(var i in editable) {
		if(editable[i]['group'] && ("|"+editable[i]['group']+"|").indexOf( "|"+grp+"|") != -1) {
			if(typeof(must) != 'undefined') {
				edit_set_must(i, must);
			} else {
				edit_set_must(i, editable_o[i]['must']);
			}
		}
	}
}


function edit_set_show_grp(grp, isshow) {
	var a = document.getElementsByTagName("div");
	for(var i = 0; i < a.length; i++) {
		var div = a[i];
		var name = div.getAttribute("name");
		if(name && ("|"+name+"|").indexOf( "|edit_grp_"+grp+"|") != -1) {
			if(isshow == 1) {
				div.style.display = '';
				edit_set_grp_must(grp);
			} else {
				edit_set_grp_must(grp, 0);
				div.style.display = 'none';
			}
		}
	}
}